fix sbitmap initialization and null_blk tagset setup#44
fix sbitmap initialization and null_blk tagset setup#44blktests-ci[bot] wants to merge 3 commits intolinus-master_basefrom
Conversation
|
Upstream branch: 89be9a8 |
81f31a4 to
87bbbbc
Compare
|
Upstream branch: 25fae0b |
4cc8be2 to
af24d2a
Compare
6637119 to
f092a9b
Compare
|
Upstream branch: 260f6f4 |
af24d2a to
66b032c
Compare
f092a9b to
0b59764
Compare
|
Upstream branch: d6084bb |
66b032c to
ddf0ba1
Compare
0b59764 to
aee5bd3
Compare
|
Upstream branch: 831462f |
ddf0ba1 to
4ced250
Compare
aee5bd3 to
ef18525
Compare
|
Upstream branch: c93529a |
4ced250 to
c81ac97
Compare
ef18525 to
3851b3f
Compare
|
Upstream branch: cbbf0a7 |
c81ac97 to
f1d1184
Compare
3851b3f to
28b3384
Compare
|
Upstream branch: 6a68cec |
f1d1184 to
ff9a3a1
Compare
28b3384 to
8ab9be5
Compare
|
Upstream branch: f2d282e |
ff9a3a1 to
66f0e52
Compare
dc096ab to
eef7f79
Compare
4c26e9a to
1356209
Compare
|
Upstream branch: 2988dfe |
eef7f79 to
48abc46
Compare
1356209 to
ae9bce3
Compare
|
Upstream branch: c30a135 |
48abc46 to
7041731
Compare
ae9bce3 to
e263d6e
Compare
|
Upstream branch: 561c803 |
7041731 to
2dc1a60
Compare
e263d6e to
77110f5
Compare
|
Upstream branch: b96ddbc |
2dc1a60 to
3890e49
Compare
77110f5 to
a2e0474
Compare
|
Upstream branch: 2b38afc |
3890e49 to
b9ffed3
Compare
|
Upstream branch: 8f5ae30 |
|
Upstream branch: 53e760d |
|
Upstream branch: 0e39a73 |
|
Upstream branch: 8742b2d |
|
Upstream branch: 91325f3 |
|
Upstream branch: 3a4a036 |
|
Upstream branch: dfc0f63 |
|
Upstream branch: 0cc5352 |
|
Upstream branch: 24ea63e |
We observed a kernel crash when the I/O scheduler allocates an sbitmap for a hardware queue (hctx) that has no associated software queues (ctx), and later attempts to free it. When no software queues are mapped to a hardware queue, the sbitmap is initialized with a depth of zero. In such cases, the sbitmap_init_node() function should set sb->alloc_hint to NULL. However, if this is not done, sb->alloc_hint may contain garbage, and calling sbitmap_free() will pass this invalid pointer to free_percpu(), resulting in a kernel crash. Example crash trace: ================================================================== Kernel attempted to read user page (28) - exploit attempt? (uid: 0) BUG: Kernel NULL pointer dereference on read at 0x00000028 Faulting instruction address: 0xc000000000708f88 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries [...] CPU: 5 UID: 0 PID: 5491 Comm: mk_nullb_shared Kdump: loaded Tainted: G B 6.16.0-rc5+ #294 VOLUNTARY Tainted: [B]=BAD_PAGE Hardware name: IBM,9043-MRX POWER10 (architected) 0x800200 0xf000006 of:IBM,FW1060.00 (NM1060_028) hv:phyp pSeries [...] NIP [c000000000708f88] free_percpu+0x144/0xba8 LR [c000000000708f84] free_percpu+0x140/0xba8 Call Trace: free_percpu+0x140/0xba8 (unreliable) kyber_exit_hctx+0x94/0x124 blk_mq_exit_sched+0xe4/0x214 elevator_exit+0xa8/0xf4 elevator_switch+0x3b8/0x5d8 elv_update_nr_hw_queues+0x14c/0x300 blk_mq_update_nr_hw_queues+0x5cc/0x670 nullb_update_nr_hw_queues+0x118/0x1f8 [null_blk] nullb_device_submit_queues_store+0xac/0x170 [null_blk] configfs_write_iter+0x1dc/0x2d0 vfs_write+0x5b0/0x77c ksys_write+0xa0/0x180 system_call_exception+0x1b0/0x4f0 system_call_vectored_common+0x15c/0x2ec If the sbitmap depth is zero, sb->alloc_hint memory is NOT allocated, but the pointer is not explicitly set to NULL. Later, during sbitmap_free(), the kernel attempts to free sb->alloc_hint, which is a per cpu pointer variable, regardless of whether it was valid, leading to a crash. This patch ensures that sb->alloc_hint is explicitly set to NULL in sbitmap_init_node() when the requested depth is zero. This prevents free_percpu() from freeing sb->alloc_hint and thus avoids the observed crash. Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Nilay Shroff <[email protected]>
When setting up a null block device, we initialize a tagset that includes a driver_data field—typically used by block drivers to store a pointer to driver-specific data. In the case of null_blk, this should point to the struct nullb instance. However, due to recent tagset refactoring in the null_blk driver, we missed initializing driver_data when creating a shared tagset. As a result, software queues (ctx) fail to map correctly to new hardware queues (hctx). For example, increasing the number of submit queues triggers an nr_hw_queues update, which invokes null_map_queues() to remap queues. Since set->driver_data is unset, null_map_queues() fails to map any ctx to the new hctxs, leading to hctx->nr_ctx == 0, effectively making the hardware queues unusable for I/O. This patch fixes the issue by ensuring that set->driver_data is properly initialized to point to the struct nullb during tagset setup. Fixes: 72ca287 ("null_blk: refactor tag_set setup") Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Nilay Shroff <[email protected]>
|
Upstream branch: d7ee5bd |
|
Upstream branch: b19a97d |
Pull request for series with
subject: fix sbitmap initialization and null_blk tagset setup
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=984340